{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Importing PulP solver\n",
    "from pulp import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Inputing the Demand points\n",
    "demand_points=['Mina Salman','Port of Haifa']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Mina Salman', 'Port of Haifa']"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "demand_points"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Inputing the Supply Points\n",
    "supply_points=['Port of Shanghai','Port of Marseille','Port of Hamburg_Germany','Port of Budapest','Port of Jawaharlal Nehru','Port of Nagoya','Port of Busan','Port of Manzanillo','Port of Kaohsiung','Port of Mersin','Port of Immingham','Port of New York','Port of Los Angeles']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Port of Shanghai',\n",
       " 'Port of Marseille',\n",
       " 'Port of Hamburg_Germany',\n",
       " 'Port of Budapest',\n",
       " 'Port of Jawaharlal Nehru',\n",
       " 'Port of Nagoya',\n",
       " 'Port of Busan',\n",
       " 'Port of Manzanillo',\n",
       " 'Port of Kaohsiung',\n",
       " 'Port of Mersin',\n",
       " 'Port of Immingham',\n",
       " 'Port of New York',\n",
       " 'Port of Los Angeles']"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "supply_points"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Inputing the distances\n",
    "distance = dict(zip(supply_points,[dict(zip(demand_points, [6882,8336])),\n",
    "dict(zip(demand_points, [5332,1946])),\n",
    "dict(zip(demand_points, [7561,4173])),\n",
    "dict(zip(demand_points, [5615,2192])),\n",
    "dict(zip(demand_points, [1589,3510])),\n",
    "dict(zip(demand_points, [7759,9214])),\n",
    "dict(zip(demand_points, [7398,8852])),\n",
    "dict(zip(demand_points, [13061,9673])),\n",
    "dict(zip(demand_points, [6316,7770])),\n",
    "dict(zip(demand_points, [3831,233])),\n",
    "dict(zip(demand_points, [7334,3944])),\n",
    "dict(zip(demand_points, [9168,5756])),\n",
    "dict(zip(demand_points, [14552,11048]))]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Port of Shanghai': {'Mina Salman': 6882, 'Port of Haifa': 8336},\n",
       " 'Port of Marseille': {'Mina Salman': 5332, 'Port of Haifa': 1946},\n",
       " 'Port of Hamburg_Germany': {'Mina Salman': 7561, 'Port of Haifa': 4173},\n",
       " 'Port of Budapest': {'Mina Salman': 5615, 'Port of Haifa': 2192},\n",
       " 'Port of Jawaharlal Nehru': {'Mina Salman': 1589, 'Port of Haifa': 3510},\n",
       " 'Port of Nagoya': {'Mina Salman': 7759, 'Port of Haifa': 9214},\n",
       " 'Port of Busan': {'Mina Salman': 7398, 'Port of Haifa': 8852},\n",
       " 'Port of Manzanillo': {'Mina Salman': 13061, 'Port of Haifa': 9673},\n",
       " 'Port of Kaohsiung': {'Mina Salman': 6316, 'Port of Haifa': 7770},\n",
       " 'Port of Mersin': {'Mina Salman': 3831, 'Port of Haifa': 233},\n",
       " 'Port of Immingham': {'Mina Salman': 7334, 'Port of Haifa': 3944},\n",
       " 'Port of New York': {'Mina Salman': 9168, 'Port of Haifa': 5756},\n",
       " 'Port of Los Angeles': {'Mina Salman': 14552, 'Port of Haifa': 11048}}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "distance"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Inputing the Fiber Demand\n",
    "Fiber_demand=dict(zip(demand_points, [13752119.49,11959623.64]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Mina Salman': 13752119.49, 'Port of Haifa': 11959623.64}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Fiber_demand"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Inputing the Fiber Supply\n",
    "Fiber_supply=dict(zip(supply_points, [7891206.716800,4720787.525080,3013639.269080,1741988.017000,1532949.455000,1498109.694000,1289071.132000,1080032.570000,1010353.050000,870994.008400,627115.686000,256623.912100,178873.092100])) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Port of Shanghai': 7891206.7168,\n",
       " 'Port of Marseille': 4720787.52508,\n",
       " 'Port of Hamburg_Germany': 3013639.26908,\n",
       " 'Port of Budapest': 1741988.017,\n",
       " 'Port of Jawaharlal Nehru': 1532949.455,\n",
       " 'Port of Nagoya': 1498109.694,\n",
       " 'Port of Busan': 1289071.132,\n",
       " 'Port of Manzanillo': 1080032.57,\n",
       " 'Port of Kaohsiung': 1010353.05,\n",
       " 'Port of Mersin': 870994.0084,\n",
       " 'Port of Immingham': 627115.686,\n",
       " 'Port of New York': 256623.9121,\n",
       " 'Port of Los Angeles': 178873.0921}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Fiber_supply"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set Problem Variables\n",
    "prob = LpProblem(\"Transportation\", LpMinimize)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Transportation:\n",
       "MINIMIZE\n",
       "None\n",
       "VARIABLES"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "prob"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set Problem Variables\n",
    "routes = [(i,j) for i in supply_points for j in demand_points]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('Port of Shanghai', 'Mina Salman'),\n",
       " ('Port of Shanghai', 'Port of Haifa'),\n",
       " ('Port of Marseille', 'Mina Salman'),\n",
       " ('Port of Marseille', 'Port of Haifa'),\n",
       " ('Port of Hamburg_Germany', 'Mina Salman'),\n",
       " ('Port of Hamburg_Germany', 'Port of Haifa'),\n",
       " ('Port of Budapest', 'Mina Salman'),\n",
       " ('Port of Budapest', 'Port of Haifa'),\n",
       " ('Port of Jawaharlal Nehru', 'Mina Salman'),\n",
       " ('Port of Jawaharlal Nehru', 'Port of Haifa'),\n",
       " ('Port of Nagoya', 'Mina Salman'),\n",
       " ('Port of Nagoya', 'Port of Haifa'),\n",
       " ('Port of Busan', 'Mina Salman'),\n",
       " ('Port of Busan', 'Port of Haifa'),\n",
       " ('Port of Manzanillo', 'Mina Salman'),\n",
       " ('Port of Manzanillo', 'Port of Haifa'),\n",
       " ('Port of Kaohsiung', 'Mina Salman'),\n",
       " ('Port of Kaohsiung', 'Port of Haifa'),\n",
       " ('Port of Mersin', 'Mina Salman'),\n",
       " ('Port of Mersin', 'Port of Haifa'),\n",
       " ('Port of Immingham', 'Mina Salman'),\n",
       " ('Port of Immingham', 'Port of Haifa'),\n",
       " ('Port of New York', 'Mina Salman'),\n",
       " ('Port of New York', 'Port of Haifa'),\n",
       " ('Port of Los Angeles', 'Mina Salman'),\n",
       " ('Port of Los Angeles', 'Port of Haifa')]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "routes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Decision Variables\n",
    "X = LpVariable.dicts(\"ShipmentAmount\",(supply_points, demand_points),0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Port of Shanghai': {'Mina Salman': ShipmentAmount_Port_of_Shanghai_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Shanghai_Port_of_Haifa},\n",
       " 'Port of Marseille': {'Mina Salman': ShipmentAmount_Port_of_Marseille_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Marseille_Port_of_Haifa},\n",
       " 'Port of Hamburg_Germany': {'Mina Salman': ShipmentAmount_Port_of_Hamburg_Germany_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Hamburg_Germany_Port_of_Haifa},\n",
       " 'Port of Budapest': {'Mina Salman': ShipmentAmount_Port_of_Budapest_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Budapest_Port_of_Haifa},\n",
       " 'Port of Jawaharlal Nehru': {'Mina Salman': ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa},\n",
       " 'Port of Nagoya': {'Mina Salman': ShipmentAmount_Port_of_Nagoya_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Nagoya_Port_of_Haifa},\n",
       " 'Port of Busan': {'Mina Salman': ShipmentAmount_Port_of_Busan_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Busan_Port_of_Haifa},\n",
       " 'Port of Manzanillo': {'Mina Salman': ShipmentAmount_Port_of_Manzanillo_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa},\n",
       " 'Port of Kaohsiung': {'Mina Salman': ShipmentAmount_Port_of_Kaohsiung_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Kaohsiung_Port_of_Haifa},\n",
       " 'Port of Mersin': {'Mina Salman': ShipmentAmount_Port_of_Mersin_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Mersin_Port_of_Haifa},\n",
       " 'Port of Immingham': {'Mina Salman': ShipmentAmount_Port_of_Immingham_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Immingham_Port_of_Haifa},\n",
       " 'Port of New York': {'Mina Salman': ShipmentAmount_Port_of_New_York_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_New_York_Port_of_Haifa},\n",
       " 'Port of Los Angeles': {'Mina Salman': ShipmentAmount_Port_of_Los_Angeles_Mina_Salman,\n",
       "  'Port of Haifa': ShipmentAmount_Port_of_Los_Angeles_Port_of_Haifa}}"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Objective Function\n",
    "prob += sum(X[i][j]*distance[i][j] for (i,j) in routes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Transportation:\n",
       "MINIMIZE\n",
       "5615*ShipmentAmount_Port_of_Budapest_Mina_Salman + 2192*ShipmentAmount_Port_of_Budapest_Port_of_Haifa + 7398*ShipmentAmount_Port_of_Busan_Mina_Salman + 8852*ShipmentAmount_Port_of_Busan_Port_of_Haifa + 7561*ShipmentAmount_Port_of_Hamburg_Germany_Mina_Salman + 4173*ShipmentAmount_Port_of_Hamburg_Germany_Port_of_Haifa + 7334*ShipmentAmount_Port_of_Immingham_Mina_Salman + 3944*ShipmentAmount_Port_of_Immingham_Port_of_Haifa + 1589*ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman + 3510*ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa + 6316*ShipmentAmount_Port_of_Kaohsiung_Mina_Salman + 7770*ShipmentAmount_Port_of_Kaohsiung_Port_of_Haifa + 14552*ShipmentAmount_Port_of_Los_Angeles_Mina_Salman + 11048*ShipmentAmount_Port_of_Los_Angeles_Port_of_Haifa + 13061*ShipmentAmount_Port_of_Manzanillo_Mina_Salman + 9673*ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa + 5332*ShipmentAmount_Port_of_Marseille_Mina_Salman + 1946*ShipmentAmount_Port_of_Marseille_Port_of_Haifa + 3831*ShipmentAmount_Port_of_Mersin_Mina_Salman + 233*ShipmentAmount_Port_of_Mersin_Port_of_Haifa + 7759*ShipmentAmount_Port_of_Nagoya_Mina_Salman + 9214*ShipmentAmount_Port_of_Nagoya_Port_of_Haifa + 9168*ShipmentAmount_Port_of_New_York_Mina_Salman + 5756*ShipmentAmount_Port_of_New_York_Port_of_Haifa + 6882*ShipmentAmount_Port_of_Shanghai_Mina_Salman + 8336*ShipmentAmount_Port_of_Shanghai_Port_of_Haifa + 0\n",
       "VARIABLES\n",
       "ShipmentAmount_Port_of_Budapest_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Budapest_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Busan_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Busan_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Hamburg_Germany_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Hamburg_Germany_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Immingham_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Immingham_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Kaohsiung_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Kaohsiung_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Los_Angeles_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Los_Angeles_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Manzanillo_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Marseille_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Marseille_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Mersin_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Mersin_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Nagoya_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Nagoya_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_New_York_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_New_York_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Shanghai_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Shanghai_Port_of_Haifa Continuous"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "prob"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Transportation:\n",
       "MINIMIZE\n",
       "5615*ShipmentAmount_Port_of_Budapest_Mina_Salman + 2192*ShipmentAmount_Port_of_Budapest_Port_of_Haifa + 7398*ShipmentAmount_Port_of_Busan_Mina_Salman + 8852*ShipmentAmount_Port_of_Busan_Port_of_Haifa + 7561*ShipmentAmount_Port_of_Hamburg_Germany_Mina_Salman + 4173*ShipmentAmount_Port_of_Hamburg_Germany_Port_of_Haifa + 7334*ShipmentAmount_Port_of_Immingham_Mina_Salman + 3944*ShipmentAmount_Port_of_Immingham_Port_of_Haifa + 1589*ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman + 3510*ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa + 6316*ShipmentAmount_Port_of_Kaohsiung_Mina_Salman + 7770*ShipmentAmount_Port_of_Kaohsiung_Port_of_Haifa + 14552*ShipmentAmount_Port_of_Los_Angeles_Mina_Salman + 11048*ShipmentAmount_Port_of_Los_Angeles_Port_of_Haifa + 13061*ShipmentAmount_Port_of_Manzanillo_Mina_Salman + 9673*ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa + 5332*ShipmentAmount_Port_of_Marseille_Mina_Salman + 1946*ShipmentAmount_Port_of_Marseille_Port_of_Haifa + 3831*ShipmentAmount_Port_of_Mersin_Mina_Salman + 233*ShipmentAmount_Port_of_Mersin_Port_of_Haifa + 7759*ShipmentAmount_Port_of_Nagoya_Mina_Salman + 9214*ShipmentAmount_Port_of_Nagoya_Port_of_Haifa + 9168*ShipmentAmount_Port_of_New_York_Mina_Salman + 5756*ShipmentAmount_Port_of_New_York_Port_of_Haifa + 6882*ShipmentAmount_Port_of_Shanghai_Mina_Salman + 8336*ShipmentAmount_Port_of_Shanghai_Port_of_Haifa + 0\n",
       "SUBJECT TO\n",
       "_C1: ShipmentAmount_Port_of_Budapest_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Busan_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Hamburg_Germany_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Immingham_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Kaohsiung_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Los_Angeles_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Manzanillo_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Marseille_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Mersin_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Nagoya_Mina_Salman\n",
       " + ShipmentAmount_Port_of_New_York_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Shanghai_Mina_Salman >= 13752119.49\n",
       "\n",
       "_C2: ShipmentAmount_Port_of_Budapest_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Busan_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Hamburg_Germany_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Immingham_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Kaohsiung_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Los_Angeles_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Marseille_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Mersin_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Nagoya_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_New_York_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Shanghai_Port_of_Haifa >= 11959623.64\n",
       "\n",
       "VARIABLES\n",
       "ShipmentAmount_Port_of_Budapest_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Budapest_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Busan_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Busan_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Hamburg_Germany_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Hamburg_Germany_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Immingham_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Immingham_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Kaohsiung_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Kaohsiung_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Los_Angeles_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Los_Angeles_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Manzanillo_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Marseille_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Marseille_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Mersin_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Mersin_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Nagoya_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Nagoya_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_New_York_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_New_York_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Shanghai_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Shanghai_Port_of_Haifa Continuous"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Constraints\n",
    "for j in demand_points:\n",
    "    prob += sum(X[i][j] for i in supply_points) >= Fiber_demand[j]\n",
    "    \n",
    "prob"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Transportation:\n",
       "MINIMIZE\n",
       "5615*ShipmentAmount_Port_of_Budapest_Mina_Salman + 2192*ShipmentAmount_Port_of_Budapest_Port_of_Haifa + 7398*ShipmentAmount_Port_of_Busan_Mina_Salman + 8852*ShipmentAmount_Port_of_Busan_Port_of_Haifa + 7561*ShipmentAmount_Port_of_Hamburg_Germany_Mina_Salman + 4173*ShipmentAmount_Port_of_Hamburg_Germany_Port_of_Haifa + 7334*ShipmentAmount_Port_of_Immingham_Mina_Salman + 3944*ShipmentAmount_Port_of_Immingham_Port_of_Haifa + 1589*ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman + 3510*ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa + 6316*ShipmentAmount_Port_of_Kaohsiung_Mina_Salman + 7770*ShipmentAmount_Port_of_Kaohsiung_Port_of_Haifa + 14552*ShipmentAmount_Port_of_Los_Angeles_Mina_Salman + 11048*ShipmentAmount_Port_of_Los_Angeles_Port_of_Haifa + 13061*ShipmentAmount_Port_of_Manzanillo_Mina_Salman + 9673*ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa + 5332*ShipmentAmount_Port_of_Marseille_Mina_Salman + 1946*ShipmentAmount_Port_of_Marseille_Port_of_Haifa + 3831*ShipmentAmount_Port_of_Mersin_Mina_Salman + 233*ShipmentAmount_Port_of_Mersin_Port_of_Haifa + 7759*ShipmentAmount_Port_of_Nagoya_Mina_Salman + 9214*ShipmentAmount_Port_of_Nagoya_Port_of_Haifa + 9168*ShipmentAmount_Port_of_New_York_Mina_Salman + 5756*ShipmentAmount_Port_of_New_York_Port_of_Haifa + 6882*ShipmentAmount_Port_of_Shanghai_Mina_Salman + 8336*ShipmentAmount_Port_of_Shanghai_Port_of_Haifa + 0\n",
       "SUBJECT TO\n",
       "_C1: ShipmentAmount_Port_of_Budapest_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Busan_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Hamburg_Germany_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Immingham_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Kaohsiung_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Los_Angeles_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Manzanillo_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Marseille_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Mersin_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Nagoya_Mina_Salman\n",
       " + ShipmentAmount_Port_of_New_York_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Shanghai_Mina_Salman >= 13752119.49\n",
       "\n",
       "_C2: ShipmentAmount_Port_of_Budapest_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Busan_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Hamburg_Germany_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Immingham_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Kaohsiung_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Los_Angeles_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Marseille_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Mersin_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Nagoya_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_New_York_Port_of_Haifa\n",
       " + ShipmentAmount_Port_of_Shanghai_Port_of_Haifa >= 11959623.64\n",
       "\n",
       "_C3: ShipmentAmount_Port_of_Shanghai_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Shanghai_Port_of_Haifa = 7891206.7168\n",
       "\n",
       "_C4: ShipmentAmount_Port_of_Marseille_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Marseille_Port_of_Haifa = 4720787.52508\n",
       "\n",
       "_C5: ShipmentAmount_Port_of_Hamburg_Germany_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Hamburg_Germany_Port_of_Haifa = 3013639.26908\n",
       "\n",
       "_C6: ShipmentAmount_Port_of_Budapest_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Budapest_Port_of_Haifa = 1741988.017\n",
       "\n",
       "_C7: ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa = 1532949.455\n",
       "\n",
       "_C8: ShipmentAmount_Port_of_Nagoya_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Nagoya_Port_of_Haifa = 1498109.694\n",
       "\n",
       "_C9: ShipmentAmount_Port_of_Busan_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Busan_Port_of_Haifa = 1289071.132\n",
       "\n",
       "_C10: ShipmentAmount_Port_of_Manzanillo_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa = 1080032.57\n",
       "\n",
       "_C11: ShipmentAmount_Port_of_Kaohsiung_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Kaohsiung_Port_of_Haifa = 1010353.05\n",
       "\n",
       "_C12: ShipmentAmount_Port_of_Mersin_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Mersin_Port_of_Haifa = 870994.0084\n",
       "\n",
       "_C13: ShipmentAmount_Port_of_Immingham_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Immingham_Port_of_Haifa = 627115.686\n",
       "\n",
       "_C14: ShipmentAmount_Port_of_New_York_Mina_Salman\n",
       " + ShipmentAmount_Port_of_New_York_Port_of_Haifa = 256623.9121\n",
       "\n",
       "_C15: ShipmentAmount_Port_of_Los_Angeles_Mina_Salman\n",
       " + ShipmentAmount_Port_of_Los_Angeles_Port_of_Haifa = 178873.0921\n",
       "\n",
       "VARIABLES\n",
       "ShipmentAmount_Port_of_Budapest_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Budapest_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Busan_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Busan_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Hamburg_Germany_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Hamburg_Germany_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Immingham_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Immingham_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Jawaharlal_Nehru_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Kaohsiung_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Kaohsiung_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Los_Angeles_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Los_Angeles_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Manzanillo_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Marseille_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Marseille_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Mersin_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Mersin_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Nagoya_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Nagoya_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_New_York_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_New_York_Port_of_Haifa Continuous\n",
       "ShipmentAmount_Port_of_Shanghai_Mina_Salman Continuous\n",
       "ShipmentAmount_Port_of_Shanghai_Port_of_Haifa Continuous"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Constraints\n",
    "for i in supply_points:\n",
    "    prob += sum(X[i][j] for j in demand_points) == Fiber_supply[i]\n",
    "prob"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Status: Optimal\n",
      "ShipmentAmount_Port_of_Budapest_Port_of_Haifa = 1741988.0\n",
      "ShipmentAmount_Port_of_Busan_Mina_Salman = 1289071.1\n",
      "ShipmentAmount_Port_of_Hamburg_Germany_Port_of_Haifa = 3013639.3\n",
      "ShipmentAmount_Port_of_Immingham_Port_of_Haifa = 627115.69\n",
      "ShipmentAmount_Port_of_Jawaharlal_Nehru_Mina_Salman = 1532949.5\n",
      "ShipmentAmount_Port_of_Kaohsiung_Mina_Salman = 1010353.0\n",
      "ShipmentAmount_Port_of_Los_Angeles_Port_of_Haifa = 178873.09\n",
      "ShipmentAmount_Port_of_Manzanillo_Port_of_Haifa = 1080032.6\n",
      "ShipmentAmount_Port_of_Marseille_Mina_Salman = 530429.44\n",
      "ShipmentAmount_Port_of_Marseille_Port_of_Haifa = 4190358.1\n",
      "ShipmentAmount_Port_of_Mersin_Port_of_Haifa = 870994.01\n",
      "ShipmentAmount_Port_of_Nagoya_Mina_Salman = 1498109.7\n",
      "ShipmentAmount_Port_of_New_York_Port_of_Haifa = 256623.91\n",
      "ShipmentAmount_Port_of_Shanghai_Mina_Salman = 7891206.7\n",
      "Total kilogram_miles = 128238711454.35002\n"
     ]
    }
   ],
   "source": [
    "prob.solve()\n",
    "\n",
    "print(\"Status:\", LpStatus[prob.status])\n",
    "\n",
    "for v in prob.variables():\n",
    "    if v.varValue > 0:\n",
    "        print(v.name, \"=\", v.varValue)\n",
    "\n",
    "print(\"Total kilogram_miles =\", value(prob.objective))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
